﻿using System.Globalization;
using System.Windows;

namespace XamlFoundation.Globalization
{
    public static class Globalization
    {
        public static CultureInfo GetLanguage(DependencyObject obj)
        {
            return (CultureInfo)obj.GetValue(LanguageProperty);
        }

        public static void SetLanguage(DependencyObject obj, CultureInfo value)
        {
            obj.SetValue(LanguageProperty, value);
        }

        // Using a DependencyProperty as the backing store for LanguageInfo.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty LanguageProperty =
            DependencyProperty.RegisterAttached("Language", typeof(CultureInfo), typeof(Globalization), 
            new FrameworkPropertyMetadata(CultureInfo.CurrentUICulture, FrameworkPropertyMetadataOptions.Inherits));


        public static ILocalizationProvider GetLocalizationProvider(DependencyObject obj)
        {
            return (ILocalizationProvider)obj.GetValue(LocalizationProviderProperty);
        }

        public static void SetLocalizationProvider(DependencyObject obj, ILocalizationProvider value)
        {
            obj.SetValue(LocalizationProviderProperty, value);
        }

        // Using a DependencyProperty as the backing store for LocalizationProvider.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty LocalizationProviderProperty =
            DependencyProperty.RegisterAttached("LocalizationProvider", typeof(ILocalizationProvider), typeof(Globalization),
            new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.Inherits));

    }
}
